<?php
/**
* @package Frontend-User-Access (com_frontenduseraccess)
* @version 3.0.8
* @copyright Copyright (C) 2008 Carsten Engel. All rights reserved.
* @license GPL versions free/trial/pro
* @author http://www.pages-and-items.com
* @joomla Joomla is Free Software
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

if(!$this->controller->fua_config['display_usergroups'] && $this->controller->user_type!='Super Administrator'){
	die('Restricted access');
}

//header and nav
$this->controller->echo_header();

?>

<script language="JavaScript" type="text/javascript">

function submitbutton(pressbutton) {
	if (pressbutton == 'usergroup') {	
		document.location.href = 'index2.php?option=com_frontenduseraccess&view=usergroup&sub_task=new';		
	}		
	if (pressbutton == 'usergroup_delete') {
		if (document.adminForm.boxchecked.value == '0') {						
			alert('<?php echo JText::_('NOSELECTUSERGROUP'); ?>');
			return;
		} else {
			if(confirm("<?php echo JText::_('SUREDELETEUSERGROUP'); ?>")){
				submitform('usergroup_delete');
			}
		}
	}
}

function check_limitstart(){
	ori_search = '<?php echo $this->search;?>';	
	new_search = document.getElementById('search').value;	
	if(ori_search!=new_search){
		document.adminForm.limitstart_needs_reset.value = 1;
	}else{
		document.adminForm.limitstart_needs_reset.value = 0;
	}	
	return true;
}



</script>

<form name="adminForm" method="post" action="">
		<input type="hidden" name="option" value="com_frontenduseraccess" />
		<input type="hidden" name="task" id="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />	
		<input type="hidden" name="limitstart_needs_reset" value="" />		
		<?php echo JHTML::_( 'form.token' ); ?>	
		<div style="text-align: right;">	
		<?php
		echo JText::_('FILTER'); ?>:
		<input type="text" name="search" id="search" value="<?php echo $this->search;?>" class="text_area"  onchange="check_limitstart();" />
		<button onclick="check_limitstart();this.form.submit();"><?php echo JText::_('GO'); ?></button>
		&nbsp;<button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo JText::_('RESET'); ?></button>
	</div>
<table class="adminlist">
	<tr>
		<th width="5" align="left">
			<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->fua_usergroups); ?>);" />			
		</th>
		<th align="left">
			<?php echo JText::_('USERGROUPS'); ?>
		</th>
		<th align="left">
			<?php echo JText::_('DESCRIPTION'); ?>
		</th>
	</tr>	

<?php


$k = 0;	
for($i=0; $i < count( $this->fua_usergroups ); $i++) {
	$row = $this->fua_usergroups[$i];		
	echo '<tr class="row'.$k.'"><td><input type="checkbox" id="cb'.$i.'" name="cid[]" value="'.$row->id.'" onclick="isChecked(this.checked);" /></td><td><a href="index2.php?option=com_frontenduseraccess&amp;view=usergroup&amp;id='.$row->id.'">'.$row->name.'</a></td>';
	echo '<td>';
	echo $row->description;
	echo '</td>';
	echo '</tr>';
	if($k==1){
		$k = 0;
	}else{
		$k = 1;
	}	
}
if(count($this->fua_usergroups)==0){
	echo '<tr><td colspan="3">'.JText::_('NOUSERGROUPS').'</td></tr>';
}
echo '<table class="adminlist"><tfoot><tr><td>'.$this->pagination->getListFooter().'</td></tr></tfoot></table>';
?>

	</tr>
</table>
</form>
<?php
$this->controller->display_footer();
?>